# cmake最低要求
cmake_minimum_required( VERSION 3.1.0 )

# 设置moc rcc uic
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

if(CMAKE_VERSION VERSION_LESS "3.7.0")
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()


# 声明一个项目
project(QtCMakeProject)

# C的中文乱码解决办法
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fexec-charset=GBK")
# C++ 的中文乱码解决办法
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fexec-charset=GBK")

# 引入所有文件夹
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/SharedModels) 
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/MainSource)
# 设置rapidjson库
SET(RapidJson ${CMAKE_SOURCE_DIR}/ThridLibaries/rapidjson/include)
INCLUDE_DIRECTORIES(${RapidJson}) 

# 提供位置定位.cmake文件
set(Qt5_DIR C:/Qt/Qt5.12.10/5.12.10/msvc2017_64/lib/cmake/Qt5/)

# 查找Qt库
find_package(Qt5 COMPONENTS Widgets REQUIRED)

# 设置输出根目录
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/Bin)

# 设置 Debug 配置下的输出目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/debug)
# 设置动态库
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/debug/lib)
# 设置静态库
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/debug/lib)
link_directories(${CMAKE_BINARY_DIR}/lib/debug)

# 设置 Release 配置下的输出目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/release)
# 设置release配置下 动态库输出目录
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/release/lib)
# 设置release配置下 静态库输出目录
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/release/lib)
link_directories(${CMAKE_BINARY_DIR}/lib/release)

# set_property(GLOBAL PROPERTY USE_FOLDERS ON) # 启用文件夹组织


# 引入opencv库
set(OpenCV_DIR D:/C++/opencv4.5/opencv_msvc64_build/install/x64/vc16/lib)

# 引入qcustomplot库
SET(Customplot ${CMAKE_SOURCE_DIR}/ThridLibaries/qcustomplot)
add_subdirectory(${Customplot})
INCLUDE_DIRECTORIES(${Customplot}) 

find_package(OpenCV REQUIRED)
add_subdirectory(MainSource)
add_subdirectory(SharedModels)

add_subdirectory(TestDemos)
